<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./js/vue-2.4.0.js"></script>
    <style>
        li{
            border:1px solid #00ff00;
            margin: 5px;
            width: 100%;
   
        } 
        li:hover{
           background-color: #00ff00;
           transition: all 0.8s ease;
        }
          /* 使用过渡效果 */
           /*【这是一个时间点】 是进入之前，元素的起始状态，此时还没有开始进入 
          【这是一个时间点】 是动画离开之后，离开的终止状态，此时，元素 动画已经结束了 */
           .v-enter,
          .v-leave-to{  
              opacity: 0;
              transform:translateY(50px)
          }
         .v-enter-active,
         .v-leave-active{
            transition: all 1s ease;
         }
      .v-move{
        transition: all 1s ease;
      }
      .v-leave-active{
       position:absolute;
      }
    </style>


</head>

<body>
    <div id="app">

        <label>
            Id:
            <input type="text" v-model="id">
        </label>
        <label>
            Name:
            <input type="text" v-model="name" @keyup.13="hello">
        </label>
        <input type="button" value="添加" @click="hello" >
        <ul>
           <transition-group appear>
                <li v-for="(item,i) in list" :key="item.id" @click="search(i)">
                        {{item.id}}-------{{item.name}}
                    </li>
           </transition-group>
        </ul>

    </div>
</body>
<script>
    var vm = new Vue({
        el: '#app',
        data: {
            id:'',
            name:'',
            list: [{
                    id: 1,
                    name: '王狗'
                },
                {
                    id: 2,
                    name: '王碧池'
                },
                {
                    id: 3,
                    name: '王傻掉'
                }
            ],
        
        },
        methods: {
            hello(){
              this.list.push({id:this.id,name:this.name})
              this.id = this.name = ''
            },
            search(i){
                this.list.splice(i,'1')
            }
        }

    })
</script>

</html>